home *** CD-ROM | disk | FTP | other *** search
/ Loadstar 8 / 008.d81 / roman numbers (.txt) < prev    next >
Commodore BASIC  |  2022-08-26  |  4KB  |  131 lines

  1. 1 poke53265,peek(53265)and247
  2. 2 poke53281,3:poke53280,3:print"[144][147]":fori=1to24:printchr$(17);:next
  3. 3 poke53265,(peek(53265)and248)+7:print
  4. 4 print" roman numbers by m.dombrowski mcmlxxxv";
  5. 5 forp=6to0step-1
  6. 6 poke53265,(peek(53265)and248)+p
  7. 7 forx=1to50:next
  8. 8 next:g=g+1:ifg<24then3
  9. 9 fort=1to999:next
  10. 10 iffl=1then12
  11. 11 fl=1:dimc$(25),d%(25),rn$(20)
  12. 12 print"[147]":print"    there was a time in europe when the   roman system of";
  13. 13 print" notation was the most   popular method of writing numbers."
  14. 14 gosub500
  15. 15 print"enter r[146] for decimal to roman conversion"
  16. 35 print"any key for roman to decimal conversion"
  17. 36 printtab(13)"enter q[146] to quit"
  18. 40 getmd$:ifmd$="r"thenprint"[147]":gosub500:gosub650
  19. 41 ifmd$=""then40
  20. 42 ifmd$="q"thenpoke53265,peek(53265)or8:goto63000
  21. 43 ifop=0thenrun57
  22. 44 printtab(13)""rn$" ="op"[146]":op=0:goto14
  23. 45 print"[147]":printtab(5)"the roman notation for numbers":iffl=1then47
  24. 46 fl=1:dimc$(25),d%(25),rn$(20)
  25. 47 print"  two principles are used here to form "spc(8)"numbers with roman";
  26. 48 print" numerals:            (1)addition, (2)subtraction."
  27. 49 printtab(11)"addition principal:"
  28. 50 printtab(8)"xxviii = x+x+v+i+i+i = 28"
  29. 51 printtab(9)"subtraction principal:"
  30. 52 print" is used in writing all[146] fours and nines"
  31. 53 print"  4=iv,9=ix,40=xl,90=xc,400=cd,900=cm"
  32. 55 printtab(14)"hit any key"
  33. 56 getmd$:ifmd$=""then56
  34. 57 print"[147]";:gosub500:print" rules:":iffl=1then62
  35. 58 fl=1:dimc$(25),d%(25),rn$(20)
  36. 62 print" first write the thousands,"
  37. 63 print" then the hundreds,";
  38. 64 print" then the tens,"
  39. 65 print" and last of all, the units"
  40. 98 iffl=1then100
  41. 99 dimc$(25),d%(25),rn$(20):fl=1
  42. 100 a$="":b=0
  43. 108 print"enter roman numeral: limit 24 characters"
  44. 110 inputa$:b=len(a$)
  45. 112 ifb=>25thenrun11
  46. 115 fori=1tob
  47. 140 c$(i)=mid$(a$,i,1):next
  48. 170 fori=1tob:ifc$(i)="m"thend%(i)=1000:next
  49. 180 ifc$(i)="d"thend%(i)=500:next
  50. 190 ifc$(i)="c"thend%(i)=100:next
  51. 200 ifc$(i)="l"thend%(i)=50:next
  52. 210 ifc$(i)="x"thend%(i)=10:next
  53. 220 ifc$(i)="v"thend%(i)=5:next
  54. 230 ifc$(i)="i"thend%(i)=1:next
  55. 231 ifb<2then300
  56. 232 fori=1tob
  57. 233 ifd%(i)<.1*(d%(i+1))thenrun45
  58. 234 ifi=b-1then237
  59. 235 next
  60. 237 ifb<3then300
  61. 238 fori=1tob
  62. 239 ifd%(i)+d%(i+1)<d%(i+2)thenrun45
  63. 240 ifi=b-1then300
  64. 241 next
  65. 300 fori=1tob:ifd%(i)=0then45
  66. 310 ifd%(i)=>d%(i+1)thene%=d%(i):f%=f%+e%:e%=0:goto340
  67. 320 ifd%(i)<d%(i+1)thene%=d%(i+1)-d%(i)
  68. 330 f%=f%+e%:e%=0:i=i+1
  69. 340 next
  70. 345 f=f%:gosub700
  71. 350 ifa$<>rn$thenrun45
  72. 400 printtab(14)""a$" ="f%"[146]":print
  73. 445 printtab(11)"another try ? y[146]es"
  74. 450 getmd$:ifmd$="y"thenrun57
  75. 455 ifmd$=""then450
  76. 499 run11
  77. 500 printtab(13)"roman numerals":print
  78. 510 print" our number                roman symbol"
  79. 520 print "[163][163][163][163][163][163][163][163][163][163][163][163][163][163][163][163][163][163][163][163][163][163][163][163][163][163][163][163][163][163][163][163][163][163][163][163][163][163][163][163]"
  80. 530 print"      1.........................i"
  81. 540 print"      5.........................v"
  82. 550 print"     10.........................x"
  83. 560 print"     50.........................l"
  84. 570 print"    100.........................c"
  85. 580 print"    500.........................d"
  86. 590 print"   1000.........................m"
  87. 600 print"[164][164][164][164][164][164][164][164][164][164][164][164][164][164][164][164][164][164][164][164][164][164][164][164][164][164][164][164][164][164][164][164][164][164][164][164][164][164][164][164]"
  88. 610 return
  89. 650 print" decimal limit: 1-99999 "
  90. 655 input"enter decimal number";f:op=f:rn$=""
  91. 660 iff<1orf=>100000thenrun11
  92. 675 m=0:cm=0:d=0:cd=0:c=0:xc=0:l=0:xl=0:ix=0:iv=0:x=0:v=0:u=0
  93. 700 iff<1000then710
  94. 702 m=int(f/1000):f=f-m*1000:iff=0then800
  95. 710 iff=>900thenf=f-900:cm=1:goto740
  96. 712 cm=0:iff=0then800
  97. 720 iff=>500thenf=f-500:d=1:goto740
  98. 722 d=0:iff=0then800
  99. 730 iff=>400thenf=f-400:cd=1:goto740
  100. 733 cd=0:iff=0then800
  101. 740 iff=>100thenc=int(f/100):f=f-c*100
  102. 750 iff=>90thenxc=1:f=f-90:goto780
  103. 755 xc=0:iff=0then800
  104. 760 iff=>50thenl=1:f=f-50:goto780
  105. 766 l=0:iff=0then800
  106. 770 iff=>40thenxl=1:f=f-40:goto780
  107. 777 xl=0:iff=0then800
  108. 780 iff=>10thenx=int(f/10):f=f-x*10
  109. 790 iff=9thenix=1:f=f-9
  110. 792 iff=>5thenv=1:f=f-5
  111. 797 iff=4theniv=1:f=f-4
  112. 799 u=f
  113. 800 ifm>0thenfori=1tom:rn$=rn$+"m":next
  114. 805 ifcm=1thenrn$=rn$+"cm":goto820
  115. 810 ifd=1thenrn$=rn$+"d":goto820
  116. 815 ifcd=1thenrn$=rn$+"cd":goto820
  117. 820 ifc<>0then:fori=1toc:rn$=rn$+"c":next
  118. 825 ifxc=1thenrn$=rn$+"xc":goto840
  119. 830 ifl=1thenrn$=rn$+"l":goto840
  120. 835 ifxl=1thenrn$=rn$+"xl":goto840
  121. 840 ifx<>0thenfori=1tox:rn$=rn$+"x":next
  122. 845 ifix=1thenrn$=rn$+"ix"
  123. 846 ifv=1thenrn$=rn$+"v"
  124. 847 ifiv=1thenrn$=rn$+"iv"
  125. 848 ifu<>0thenfori=1tou:rn$=rn$+"i":next
  126. 850 return
  127. 63000 rem    connect back to l.s.
  128. 63001 poke53265,27: rem  fix screen
  129. 63002 print"[147]load"chr$(34)"payload"chr$(34)",8":print"run"
  130. 63004 poke198,0:poke631,13:poke632,13:poke198,2:end
  131.